package com.adui.mgt.performance.common;

import cn.dev33.satoken.stp.StpUtil;
import com.adui.mgt.performance.entity.BaseEntity;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import java.util.Date;
import java.util.Objects;

public class CommonUtil {

    public static void handleObjLog(BaseEntity entity) {
        String username = (String) StpUtil.getLoginId();
        if (StringUtils.isBlank(entity.getCreateBy())) {
            entity.setCreateBy(username);
        }
        if (Objects.isNull(entity.getCreateOn())) {
            entity.setCreateOn(new Date());
        }
        entity.setUpdateBy(username);
        entity.setUpdateOn(new Date());
    }
}
